import type { GoodsResult } from '@/types/goods'
import { http } from '@/utils/http'
import type { FileData, MealResult } from '@/types/goods'
/**
 * 商品详情
 * @param id 商品id
 */
export const getGoodsByIdAPI = (id: string) => {
  return http<GoodsResult>({
    method: 'GET',
    url: '/goods',
    data: { id },
  })
}

/**
 * 图片上传
 * @param data 请求参数
 */
export const postPictureAPI = (data: FileData) => {
  return http({
    method: 'POST',
    url: '/meal/picture',
    data,
  })
}

/**
 * 套餐列表获取
 * @param data 请求参数
 */
export const getMealListAPI = (mealtype: string, addressid: string) => {
  return http<MealResult[]>({
    method: 'GET',
    url: '/meal/meal',
    data: { mealtype, addressid },
  })
}

/**
 * 套餐详情获取
 * @param data 请求参数
 */
export const getMealListByIDAPI = (id: string) => {
  return http<MealResult[]>({
    method: 'GET',
    url: '/meal/meal',
    data: { id },
  })
}

/**
 * 创建套餐
 * @param data 请求参数
 */
export const postMealAPI = (data: MealResult) => {
  return http({
    method: 'POST',
    url: '/meal/meal',
    data,
  })
}

/**
 * 更新套餐
 * @param data 请求参数
 */
export const putMealAPI = (data: MealResult) => {
  return http({
    method: 'PUT',
    url: '/meal/meal',
    data,
  })
}

/**
 * 删除套餐
 * @param data 请求参数
 */
export const deleteMealAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: '/meal/meal',
    data: { id },
  })
}
